package com.cyan.note.enums;

import lombok.Getter;

/**
 * 用户角色枚举
 * 
 * @author ZhangzhenYu
 * @since 2025-01-13
 */
@Getter
public enum UserRole {
    
    /**
     * 超级管理员
     */
    SUPER_ADMIN("super_admin", "超级管理员"),
    
    /**
     * 店长
     */
    MANAGER("manager", "店长"),
    
    /**
     * 打手
     */
    WORKER("worker", "打手");

    private final String code;
    private final String name;

    UserRole(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code获取枚举
     */
    public static UserRole fromCode(String code) {
        for (UserRole role : values()) {
            if (role.code.equals(code)) {
                return role;
            }
        }
        throw new IllegalArgumentException("未知的用户角色: " + code);
    }
}